﻿using System;
namespace Kis.Xroad.Eu {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="InlineSimpleType", Namespace="http://kis.x-road.eu/", Target=typeof(InlineSimpleType))]
    public class InlineSimpleTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected InlineSimpleType clazz;
        
        public InlineSimpleTypeSerializer(InlineSimpleType clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXmlAttributes(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXmlAttributes(Writer);
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("BirthDate");
            if (clazz.BirthDate!=null) {
                Writer.WriteString(clazz.BirthDate.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : BirthDate");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXmlAttributes(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXmlAttributes(Reader);
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="BirthDate") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>InlineSimpleType>BirthDate");
                }
                clazz.BirthDate = new InlineSimpleType.BirthDateType(Reader.ReadElementString("BirthDate"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>InlineSimpleType>BirthDate", Reader.LocalName);
            }
        }
    }
}
